import { Button, Form, Input, message, Select } from "antd"
import { Add_Post } from "../../service/organization";
const { TextArea } = Input;
export const AddDuty = (props) => {
  // 表单实例
  const [dutyForm] = Form.useForm();
  // 岗位等级选项
  const levelOptions = [
    { label: '低级', value: '低级' },
    { label: '中级', value: '中级' },
    { label: '高级', value: '高级' },

  ];


  return <>
    <div className="modal-box">
      <Form
        form={dutyForm}
        layout="vertical"
        initialValues={{
          level: '低级',
          quota: 1,
          isKey: false
        }}
      >
        <Form.Item
          name="name"
          label="岗位名称"
          rules={[{ required: true, message: '请输入岗位名称' }]}
        >
          <Input placeholder="请输入岗位名称" />
        </Form.Item>



        <Form.Item
          name="level"
          label="岗位等级"
          rules={[{ required: true, message: '请选择岗位等级' }]}
        >
          <Select placeholder="请选择岗位等级">
            {levelOptions.map(option => (
              <Select.Option key={option.value} value={option.value}>
                {option.label}
              </Select.Option>
            ))}
          </Select>
        </Form.Item>




        <Form.Item
          name="responsibility"
          label="岗位职责"
          rules={[{ required: true, message: '请输入岗位名称' }]}
        >
          <Input placeholder="请输入岗位名称" />
        </Form.Item>

        <Form.Item
          name="remark"
          label="备注"
         
        >
          <TextArea
            rows={5}
           
          />
        
        </Form.Item>
      </Form>
      <div>
        <Button onClick={async () => {
          const formData = await dutyForm.validateFields();
          
          const res=await Add_Post(formData);
          if(res.code==0){
            message.success("新增成功");
            props.onCancel();
          }
      

        }}>确认</Button>
      </div>
    </div>
  </>
}